package cn.net.xyan.easy.gwt.client;

import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.user.client.rpc.RpcRequestBuilder;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by zarra on 16/2/18.
 */
public class EZRpcRequestBuilder extends RpcRequestBuilder {

    Map<String,String> headers = new HashMap<>();

    public void setHeader(String key,String value){
        headers.put(key,value);
    }

    @Override
    protected void doFinish(RequestBuilder rb) {
        super.doFinish(rb);
        for (String key : headers.keySet()){
            String value = headers.get(key);
            rb.setHeader(key,value);
        }
    }
}
